package com.hunanwenli.movie.aspectj;

import com.alibaba.fastjson.JSON;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author wanzhenyu
 * @date 2021/8/13 23:32
 */
@Component
@Aspect
public class DaoAspectj {
    private static final Logger logger = Logger.getLogger(DaoAspectj.class);
    @Pointcut("execution(* com.hunanwenli.movie.service.impl.daoImp.*.*(..))")
    public void dao() {
    }
    @Around(value = "dao()")
    public Object  daoAround(ProceedingJoinPoint pjp){
        logger.debug("连接点的方法定义"+pjp.getSignature()+"参数："+ JSON.toJSONString(pjp.getArgs()));
        System.out.println(pjp.getSignature());
        Object proceed = null;
        try {
            proceed = pjp.proceed();
         logger.debug("返回值"+proceed);
        } catch (Throwable throwable) {
           logger.debug(throwable);
        }
        return  proceed;
    }

}
